package com.snailxr.base.task.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import com.snailxr.base.task.dao.XZSPDao;
import com.snailxr.base.task.domain.jx.XZSP;

@Repository("xzspDaoImpl")
public class XZSPDaoImpl implements XZSPDao {

	public final Logger log = Logger.getLogger(this.getClass());
	@Resource(name="mongoTemplate")
	private MongoTemplate mongoTemplate;
	private String collectionName;//集合名
	
	@Override
	public List<XZSP> selectAll() {
		List<XZSP> list = mongoTemplate.findAll(XZSP.class);
		return list;
	}

	@Override
	public void insert(XZSP xzsp) {
		mongoTemplate.insert(xzsp);
	}

	@Override
	public void deleteAll() {
		Query query = new Query();
		mongoTemplate.findAllAndRemove(query, collectionName);
		
	}
	
	public MongoTemplate getMongoTemplate() {
		return mongoTemplate;
	}

	public void setMongoTemplate(MongoTemplate mongoTemplate) {
		this.mongoTemplate = mongoTemplate;
	}

	public String getCollectionName() {
		return collectionName;
	}

	public void setCollectionName(String collectionName) {
		this.collectionName = collectionName;
	}

}
